package com.qqhru.oj.judge;

import com.qqhru.oj.judge.strategy.DefaultJudgeStrategy;
import com.qqhru.oj.judge.strategy.JavaLanguageJudgeStrategy;
import com.qqhru.oj.judge.strategy.JudgeContext;
import com.qqhru.oj.judge.strategy.JudgeStrategy;
import com.qqhru.oj.judge.codesandbox.model.JudgeInfo;
import com.qqhru.oj.model.entity.QuestionSubmit;
import org.springframework.stereotype.Service;

/**
 * @description 判题管理（简化调用）
 */
@Service
public class JudgeManager {
    /***
    *@description 执行判题
    *@param judgeContext
    *@return
    */
    JudgeInfo doJudge(JudgeContext judgeContext){
        QuestionSubmit questionSubmit = judgeContext.getQuestionSubmit();
        String language = questionSubmit.getLanguage();
        JudgeStrategy judgeStratqegy = new DefaultJudgeStrategy();
        if ("java".equals(language)){
            judgeStratqegy = new JavaLanguageJudgeStrategy();
        }
        return judgeStratqegy.doJudge(judgeContext);
    }
}
